/*
 * Copyright 2021-2030 itbox.com All right reserved. This software is the confidential and proprietary information
 * of itbox.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered into with itbox.com.
 */
package cn.itbox.example.application.controller;

import cn.itbox.example.model.request.CreateUserRequest;
import cn.itbox.example.model.request.UpdateUserRequest;
import cn.itbox.example.model.response.UserResponse;
import cn.itbox.example.service.UserService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongProject uap
 * @BelongPackage cn.itbox.example.application.controller
 * @Description TODO
 * @ClassName RoleController
 * @Author xingc
 * @Date 2023/12/15 9:30
 * @Version 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping
    public Long create(@RequestBody @Valid CreateUserRequest request) {
        return userService.create(request);
    }

    @PutMapping
    public void update(@RequestBody @Valid UpdateUserRequest request) {
        userService.update(request);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        userService.delete(id);
    }

    @GetMapping
    public List<UserResponse> list() {
            return userService.list();
    }
}
